package com.hbnu.commonclass;

/**
 * @author kittychen
 * @since 2025-09-24 17:26
 */
public class StringDemo {
    public static void main(String[] args) {
        String str = "china";
        String str1 = new String("china");
        System.out.println(str == str1);  // false
        System.out.println(str.equals(str1));  // true
        String str2 = "china";
        System.out.println(str == str2); // true


        String content = " Learning English is like building a house. " +
                "Laying a strong foundation is the first and most important step. " +
                "In other words, you should read and speak English every day. ";
        System.out.println(content.length());
        System.out.println(content.indexOf('a'));
        System.out.println(content.lastIndexOf('a'));
        System.out.println(content.substring(3));
        System.out.println(content.substring(3, 10));   // 包含起始位置，不包含结束位置

        System.out.println("======================");
        System.out.println(content.trim());
        System.out.println(content.toUpperCase());
        String[] strs = content.split("\\.");
        for (String s : strs) {
            System.out.println(s);
        }
    }
}
